#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <iostream>
#include <math.h>

#include "ShortHoleBlock.h"

// Material Properties
GLfloat shblock1_diffuse[] = {0.50, 0.50, 0.50, 1.0};

ShortHoleBlock::ShortHoleBlock(void) {
	glColor3f(1,1,1);

	topWidth = 1.0;
	topLength = 1.0;
	topHeight = 0.175;
	botWidth = 1.0;
	botLength = 1.0;
	botHeight = 0.175;
	leftWidth = 1.0;
	leftLength = 0.25;
	leftHeight = 0.25;
	rightWidth = 1.0;
	rightLength = 0.25;
	rightHeight = 0.25;
	loadImage();
}

//function to load the images to use as textures
void ShortHoleBlock::loadImage() {
	Image* image = loadBMP("textures\\redbrick.bmp");
	blockTexture = loadTexture(image);
	delete image;
}

void ShortHoleBlock::display() {
	glPushMatrix();

		//create the texture for the block, set to 'red brick'
		glBindTexture(GL_TEXTURE_2D, blockTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glMaterialfv(GL_FRONT, GL_DIFFUSE, shblock1_diffuse);
		glTranslatef(0.0, .98 , 0.0);
		glPushMatrix();
			//top short block
			glScalef(topLength, topHeight, topWidth);
			glColor3f(0.5, 0.5, 0.5);
			//glutSolidCube(1.0);
			drawCube();
		glPopMatrix();
		
		glPushMatrix();
			//bottom short block
			glTranslatef(0.0, -topHeight*2.25, 0.0);
			glScalef(botLength, botHeight, botWidth);
			glColor3f(0.5, 0.5, 0.5);
			//glutSolidCube(1.0);
			drawCube();
		glPopMatrix();

		glPushMatrix();
			//left short block
			glTranslatef(-topLength/2.65, -topHeight*1.1, 0.0);
			glScalef(leftLength, leftHeight, leftWidth);
			glColor3f(0.5, 0.5, 0.5);
			//glutSolidCube(1.0);
			drawCube();
		glPopMatrix();

		glPushMatrix();
			//right short block
			glTranslatef(topLength/2.65, -topHeight*1.1, 0.0);
			glScalef(rightLength, rightHeight, rightWidth);
			glColor3f(0.5, 0.5, 0.5);
			//glutSolidCube(1.0);
			drawCube();
		glPopMatrix();
		//drawCube();
		//glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	
}

ShortHoleBlock::~ShortHoleBlock(void) {}
